package com.fqgj.xjd.user.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserAuthBankDao;
import com.fqgj.xjd.user.entity.UserAuthBankEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: zhangxingyun
 * Date: 2017-07-20
 * Time: 18:38:52.931
 */

@Repository
public class UserAuthBankDaoImpl extends AbstractBaseMapper<UserAuthBankEntity> implements UserAuthBankDao {

    @Override
    public int deleteByUserCode(String userCode) {
        return getSqlSession().delete(getStatement("deleteByUserCode"), userCode);
    }

    @Override
    public UserAuthBankEntity selectUserBankByUserCode(String userCode) {
        return getSqlSession().selectOne(getStatement("selectUserBankByUserCode"), userCode);

    }

    @Override
    public List<UserAuthBankEntity> selectAllUserBankByUserCode(String userCode) {
        return getSqlSession().selectList(getStatement("selectAllUserBankByUserCode"), userCode);

    }

    @Override
    public List<UserAuthBankEntity> selectUserBankByUserCodes(List<String> userCodes) {
        return getSqlSession().selectList(getStatement("selectUserBankByUserCodes"), userCodes);
    }

    @Override
    public String isBankBinded(String cardNo, Integer biz, String appCode) {
        Map params = new HashMap();
        params.put("cardNo", cardNo);
        params.put("biz", biz);
        params.put("appCode", String.valueOf(appCode));
        return getSqlSession().selectOne(getStatement("isBankBinded"), params);
    }

    @Override
    public int updateByUserCode(UserAuthBankEntity userAuthBankEntity) {
        return getSqlSession().update(getStatement("updateByUserCode"), userAuthBankEntity);
    }

}